d<extend name="Public:base" />
<block name="content">
  <div class="row">
  	<div class="col-xs-12">
        <volist name="feedback" id="vo">
			<div class="table-responsive">
				<table class="table table-striped table-bordered table-hover search-form">
					<thead>
				    <th>
                        {$vo.add_time} <php>echo $vo['user_type']==1? '业主上传了凭证' : ($vo['user_type']== 2 ? '师傅上传了凭证' : '客服发表了评论')</php>
						</th>
					</thead>
					<tbody>
						<td style="background-color: #fff;">
                            <php>if($vo['user_type']!='3'){</php>
							<div class="row">
								<div class="col-xs-1">凭证图片：</div>
								<div class="col-xs-11">
                                    <php>if($vo['certificate1']){</php>
                                    <img style="margin-right: 15px;" osctype="image" src="{$vo.certificate1}"/>
                                    <php>}</php>
                                    <php>if($vo['certificate2']){</php>
                                    <img style="margin-right: 15px;" osctype="image" src="{$vo.certificate2}"/>
                                    <php>}</php>
                                    <php>if($vo['certificate3']){</php>
                                    <img style="margin-right: 15px;" osctype="image" src="{$vo.certificate3}"/>
                                    <php>}</php>
                                    <php>if($vo['certificate4']){</php>
                                    <img style="margin-right: 15px;" osctype="image" src="{$vo.certificate4}"/>
                                    <php>}</php>
                                    <php>if($vo['certificate5']){</php>
                                    <img style="margin-right: 15px;" osctype="image" src="{$vo.certificate5}"/>
                                    <php>}</php>
                                    <php>if($vo['certificate6']){</php>
                                    <img style="margin-right: 15px;" osctype="image" src="{$vo.certificate6}"/>
                                    <php>}</php>
                                    <php>if(!$vo['certificate1']){</php>
							   		<img style="margin-right: 15px;" osctype="image" <if condition="$site['SITE_ICON']['value']">
													src="__ROOT__/<?php echo resize($site['SITE_ICON']['value'],100,100); ?>"
													<else />
													src="__ROOT__/Common/image/no_image_40x40.jpg"
													</if> />
                                    <php>}</php>
								</div>
								<div class="col-xs-1" style="padding-right: 0; margin-top: 10px;">凭证说明：</div>
								<div class="col-xs-11" style="padding-left: 0; margin-top: 10px;">
									{$vo.content}
								</div>
							</div>
                            <php>}else{</php>
                            <div class="row">
                                <div class="col-xs-1" style="padding-right: 0; margin-top: 10px;">内容：</div>
                                <div class="col-xs-11" style="padding-left: 0; margin-top: 10px;">
                                    {$vo.content}
                                </div>
                            </div>
                            <php>}</php>
						</td>
					</tbody>
				</table>
			</div>
        </volist>
	<div class="row">
		<div class="col-xs-12">
			<form class="form-horizontal"  id="form" method="post" action="{:U('Settings/save')}">
				<div class="form-group clearfix">
					<div class="col-sm-6">
			      <!--加载编辑器的容器-->
			      <script id="edit"  name="content" type="text/plain">{$detail.content|html_entity_decode}</script>
					</div>
					<div class="col-sm-2">
						<a class="btn btn-primary btn-sm radius5" id="comment">客服发表评论</a>
					</div>
				</div>

				<div class="form-group clearfix">
					<label class="col-sm-1"> 客服处理：</label>
					<div class="col-sm-11">
							<label class="radio-inline"><input type="radio" value="1" name="refund">退款</label>
							<label class="radio-inline"><input type="radio" value="2" name="refund">不退款</label>
					</div>
				</div>

				<!--<div class="form-group clearfix">-->
					<!--<label class="col-sm-1"> 退款金额：</label>-->
					<!--<div class="col-sm-11">-->
						<!--<input></input> 元-->
					<!--</div>-->
				<!--</div>-->


				<div class="form-group clearfix">
					<label class="col-sm-1"> 说明：</label>
					<div class="col-sm-10">
			      <!--加载编辑器的容器-->
			      <script id="edit2"  name="content" type="text/plain">{$detail.content|html_entity_decode}</script>
					</div>
				</div>


				<div class="form-group clearfix">
					<div class="col-sm-10">
                            <a class="btn btn-sm btn-primary radius5" id="commit">提交</a>
							<a href="{:U('Order/normal')}/order_id/{:I('order_id')}/status/refund" class="btn btn-sm btn-primary radius5">返回</a>
					</div>
				</div>
			</form>
		</div>
	</div>
</block>
<block name="javascript">
    <!-- 配置文件 -->
    <script type="text/javascript" src="__PUBLIC__/ueditor/ueditor.config.js"></script>
    <!-- 编辑器源码文件 -->
    <script type="text/javascript" src="__PUBLIC__/ueditor/ueditor.all.js"></script>
	<script type="text/javascript">
	$(function(){

		$("#search").click(function () {
	        var url = $(this).attr('url');
	        var query = $('.search-form').find('input,select').serialize();
	        query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g, '');
	        query = query.replace(/^&/g, '');
	        if (url.indexOf('?') > 0) {
	            url += '&' + query;
	        } else {
	            url += '?' + query;
	        }
	        window.location.href = url;
	    });

	});

	// 实例化编辑器

	  var ue = UE.getEditor('edit');
	  var ue = UE.getEditor('edit2');
	  ue.ready(function () {
	      //设置编辑器的内容
	      // ue.setContent();
	      //获取html内容，返回: <p>hello</p>
	      html = ue.getContent();
	      //获取纯文本内容，返回: hello
	      txt = ue.getContentTxt();
	  });
	  $('#mybtn').click(function(){
	      var ue = UE.getEditor('edit');
	      var html = ue.getContent();
	      var title=$('#title').val()
	      var status=$('input:radio[name="status"]:checked').val();
	      console.log(status)
	     $.ajax({
	          url:"{:U('Activity/add')}",
	          type:"post",
	          data:{
	              content:html,
	              title:title,
	             status:status,
	          },
	          success:function(data){
	              location.reload();
	              alert("添加成功")
	         }
	      });
	 });


      //客服发表评论
      $("#comment").click(function(){
          var ue = UE.getEditor('edit');
          var html = ue.getContentTxt();
          $.ajax({
             url:"{:U('Order/service_comment')}",
             type:"post",
             data:{
                 description: html,
                 order_id : "{:I('order_id')}"
             },
             success:function(data){
                 if(data==1){
                     $.jbox.info('评论成功','提示信息');
                 }
                 window.location.reload();
             }
          });

      });

      //客服同意/不同意 退款
      $("#commit").click(function(){
          var type = $("input[name=refund]:checked").val();
          var ue = UE.getEditor('edit2');
          var html = ue.getContentTxt();
          var order_id = "{:I('order_id')}";
          if(type==2) {
              $.ajax({
                  url: "{:U('Order/refundRefuse')}",
                  type:"post",
                  data:{
                      order_id : order_id,
                      content : html
                  },
                  success:function(data){
                      if(data==1){
                          $.jbox.info('处理成功','提示信息');
                          window.setTimeout(function () {window.location.href="{:U('Order/index')}"; }, 500);
                      }else if(data==2){
                          $.jbox.info('处理失败','提示信息');
                      }else if(data==3){
                          $.jbox.info('订单状态出错','提示信息');
                      }
                  }
              });
          }else if(type==1){
              $.ajax({
                 url:"{:U('Pingpp/AgreeRefund')}",
                 type:"post",
                 data:{
                     order_id :  order_id,
                     description :html
                 },
                  success:function(data){
					  if(data==1){
						  $.jbox.info('处理成功','提示信息');
						  window.setTimeout(function () {window.location.href="{:U('Order/index')}"; }, 500);
					  }
//					  var data = eval("(" + data + ")");
//					  var url = data.failure_msg;
//
//					  var result = UrlRegEx(url);
//
//					  window.location.href=result;

					  console.log(data)
                  }
              });

          }

      });

	function UrlRegEx(url)
	{
		//如果加上/g参数，那么只返回$0匹配。也就是说arr.length = 0
		var re = /^http([.*])RSA$/g;
		//re.exec(url);
		var arr = url.match(re);
		return arr;

	}


	</script>
</block>